<?php
   
/**
 * Mapper for Login
 * 
 * @author Martin Grossmann <snake.aas@gmail.com>
 * @version 1.0
 * @package Mappers
 *
 * @property int $idUser 
 * @property string $Token Unique token identifying user. 32 chars max
 * 
 * 
 * @entity
 * @table(name="tlogins")
 */     
class Login {
  /**
   * 
   * 
   * @access private
   * @var int
   *    
   * @column(name="idUser", type="integer")
   */
   private $idUser;
     
  /**
   * 
   * 
   * @access private
   * @var string
   * 
   * @Id
   * @column(name="token", type="string", length=32)
   */
   private $token;
       
   /*
    *
    * @access private
    * @var string 
    * 
    * column(name="sessionId", type="string", length=30, nullable=true)
    *
   private $sessId;*/

  public function __get($name) {
   
    switch($name) {
      case "idUser": 
        return $this->idUser;
        break;
     
      case "Token": 
        return $this->token;
        break;      
      
      default: 
        throw new EntityException(sprintf(T_("Trying to get undefined property")." ", $name));
      /*
      case "SessionID": 
        return $this->sessId;
        break; */     
    }
  }  
  
  public function __set($name, $value) {    
    
    switch($name) {
      case "idUser": 
        $this->idUser = Validations::validateInteger($value, null, null, false);
        break; 

      case "Token": 
        $this->token = Validations::validateString($value, 32, null, true);
        break; 
      
      default: 
        throw new EntityException(sprintf(T_("Trying to set undefined property")." ", $name));
/*
      case "SessionID": 
        $this->sessId = Validations::validateString($value, 30, null, true);
        break; */
    }
  }  
  
}